# -*- coding:utf-8 -*-
'''
定义栈的数据结构，请在该类型中实现一个能够得到栈最小元素的min函数。

解题思路：入栈的时候和辅助站进行比较如果小则入栈否则再次将最小值入栈
'''
class Solution:
    def __init__(self):
        self.stack = []
        self.assist = []

    def push(self, node):
        # write code here
        if node:
            self.stack.append(node)
        min = self.min()
        if node < min or not min:
            self.assist.append(node)
        else:
            self.assist.append(min)

    def pop(self):
        # write code here
        if self.stack:
            self.assist.pop()
            return self.stack.pop()

    def top(self):
        if self.stack:
            return self.stack[-1]

    def min(self):
        if self.assist:
            return self.assist[-1]
